<?php	
class Obj_LocationContentPage {
	
	protected static $t;
	
	public static function init() {
		self::$t = new Obj_DBTable_LocationContentPage();
	}
	
	public static function getLocationContentPages($parent, $type, $activeOnly = false) {
		$ar_ = self::$t->getLocationContentPages($parent, $type, $activeOnly);
		$ar = array();
		foreach ($ar_ as $k => $v) {
			$ar[$v['ID']] = $v;
		}
		return $ar;
	}
	
	public static function saveLocationContentPage($arData, $id) {
		if ((int)$id == (int)0) {
			return self::$t->insert($arData);
		}
		else self::$t->update($arData, 'ID = '.intval($id));
		return intval($id);
	}
	
	public static function getLocationContentPage($id) {
		return self::$t->getLocationContentPage($id);
	}
	
	public static function findLocationContentPage($parent, $type, $alias) {
		return self::$t->findLocationContentPage($parent, $type, $alias);
	}
	
	public static function delLocationContentPage($id){
		return self::$t->delete('ID = '.intval($id));
	}
	
	public static function getLink($c) {
		$row = self::$t->getLinkRow($c['ID'], $c['ParentType']);
		if (!$row) return false;
		$link = '/'.implode('/', array_reverse($row));
		return $link;
	}
	
}Obj_LocationContentPage::init();

